<h1>
	Crawler Image IIM!!
</h1>


<script>
var photos = <?php echo @CJSON::encode($photos);?>;




var app = angular.module('crawler', []);
 
app.controller('PhotosCtrl', function ($scope) {
	
	$scope.checkRequest = false;
	$scope.photos = photos;
	$scope.color = " padding:10px; margin:5px 0; color:#333; background-color: #dff0d8;border-color: #d6e9c6;";
	var crawler = function() {
		if(!$scope.checkRequest){
			
			$scope.checkRequest = true;
			$.get("<?php echo Yii::app()->createUrl('/crawler/crawler');?>",{sort:"<?php echo $sort;?>"},function(res){
				photos.unshift(res.data);
				$scope.photos = photos;
				$scope.checkRequest = false;
				$("#total").html(res.count);
			}).fail(function() {
				$scope.checkRequest = false;
				$scope.color = "background-color:#f2dede";
			});
		}
	};
	var timer = setInterval(function() {
		
		$scope.$apply(crawler);
	}, 1500);
	
});
</script>
<div>
<h2>Total image crawler: <label id="total"><?php echo count($photos);?></label></h2>
</div>
<div class="table table-hover"  ng-controller="PhotosCtrl">
	<div  ng-repeat="photo in photos" style="{{color}}">
		{{photo.new_image}} - {{photo.image}} - Status: {{photo.status}} - ID: {{photo.id}}
		- <a href="<?php echo Yii::app()->baseUrl;?>/img_vulhlh/photos/600/{{photo.new_image}}" target="_blank">600</a>
		- <a href="<?php echo Yii::app()->baseUrl;?>/img_vulhlh/photos/100-75/{{photo.new_image}}" target="_blank">100-75</a>
	</div>
</div>
<hr>
<div class="table table-hover" >
    
</div>
